//
//  TableViewViewModel.m
//  iOSCodeLearning
//
//  Created by TFAppleWork-Summer on 2018/4/13.
//  Copyright © 2018年 Ace. All rights reserved.
//

#import "TableViewViewModel.h"
#import "model.h"
#import "CellViewModel.h"

@interface TableViewViewModel()

/**
 数据
 */
@property (nonatomic, strong) NSMutableArray *datas;



@end

@implementation TableViewViewModel


-(void)getListData:(void (^)(void))complete{
    
    for (NSInteger i = 0; i<50; i++) {
        NSLog(@"模仿网络请求获取数据");
        model *m = [[model alloc ]init];
        m.index = i ;
        CellViewModel *cellViewModel = [[CellViewModel alloc]init];
        cellViewModel.actionHandle = self.actionHandler;
        cellViewModel.model = m;
        [self.datas addObject:cellViewModel];
    }
    if (complete) {
        complete();
    }
}


-(NSInteger)numberOfSection{
    return 1;
}

-(NSInteger)numberOfCell{
    return self.datas.count;
}

-(CellViewModel *)modelOfIndexPath:(NSIndexPath *)indexPath{
    CellViewModel*cellViewModel = self.datas[indexPath.row];
    return cellViewModel;
}





-(NSMutableArray*)datas{
    if (!_datas) {
        _datas= [[NSMutableArray alloc] init];
    }
    return _datas;
}

-(void)dealloc{
    NSLog(@"-----%@--------",NSStringFromClass([self class]));
}
@end
